<template>
  <div class="search">
    <el-form ref="searchRef" :model="searchForm" :rules="formRoules" label-width="100px">
      <el-form-item :label="searchTitle" prop="name">
        <el-input v-model="searchForm.name" placeholder="请输入" clearable></el-input>
      </el-form-item>
      <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询 </el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'Search',
  data() {
    return {
      searchForm: {
        name: ''
      },
      formRoules: {
        name: [{ required: true, message: '请输入内容', trigger: 'change' }]
      }
    }
  },
  props: {
    searchTitle: {
      type: String,
      default: '内容搜索:'
    }
  },

  methods: {
    onSubmit() {
      // this.$refs.searchRef.validate((valid) => {
      //   console.log(valid)
      // })
      // console.log(1)
      this.$emit('sendInfo', this.searchForm.name)
    }
  }
}
</script>

<style lang="less" scoped>
.search {
  width: 100%;
  height: 64px;
  margin-bottom: 20px;
  background-color: #fff;
  border-radius: 5px;
  box-shadow: 1px 1px 10px rgb(240, 239, 239);
  .el-form {
    display: flex;
    .el-form-item {
      margin-top: 13px;
      .el-input {
        width: 206px;
        /deep/.el-input__inner {
          height: 36px;
        }
      }
    }
    .el-button {
      align-items: center;
      min-width: 80px;
      height: 34px;
      margin-top: 16px;
      margin-left: 15px;
      padding: 0;
      background-color: #5f84ff;
      border: none;
    }
  }
}
</style>
